package stringutils

import (
	"encoding/base64"
	"math/rand"
	"time"
)

const words = "012345789abcdefghijklmnopqrstuvwxyz"

func RandomStr(l int) string {
	bWords := []byte(words)
	res := []byte{}
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < l; i++ {
		res = append(res, bWords[r.Intn(len(bWords))])
	}
	return string(res)
}

func B64Decoder(input string) string {
	//sEnc := base64.StdEncoding.EncodeToString([]byte(input))

	sDec, err := base64.StdEncoding.DecodeString(input)
	if err != nil {
		return ""
	}
	return string(sDec)
}
